package cn.beausoft.mybatis3.test.dao.auto;

import cn.beausoft.mybatis3.sqlbuild.Handle;
import cn.beausoft.mybatis3.sqlbuild.condition.ManyCondition;
import cn.beausoft.mybatis3.sqlbuild.dao.ReadBaseDao;
import cn.beausoft.mybatis3.sqlbuild.dao.WriteBaseDao;
import cn.beausoft.mybatis3.sqlbuild.query.QColumn;
import cn.beausoft.mybatis3.sqlbuild.query.QTable;
import cn.beausoft.mybatis3.test.entity.FileResource;
import java.util.List;
import java.util.Date;

/**
 * 文件资源表
 * @author hjp
 **/
public interface FileResourceAutoDao extends ReadBaseDao<FileResource>, WriteBaseDao<FileResource> {
    QTable<FileResource> TABLE = new QTable<>("file_resource");   //文件资源表
    //region filds
    QColumn<FileResource, Integer> resourceId = new QColumn<>(TABLE, "resource_id");    //资源id
    QColumn<FileResource, String> resourceName = new QColumn<>(TABLE, "resource_name");    //资源名称
    QColumn<FileResource, String> resourceFolderPath = new QColumn<>(TABLE, "resource_folder_path");    //文件所在目录路径
    QColumn<FileResource, String> resourceFileName = new QColumn<>(TABLE, "resource_file_name");    //文件名称
    QColumn<FileResource, Integer> resourceType = new QColumn<>(TABLE, "resource_type");    //文件类型
    QColumn<FileResource, Date> resourceCreateDate = new QColumn<>(TABLE, "resource_create_date");    //文件创建时间
    QColumn<FileResource, Date> resourceUpdateDate = new QColumn<>(TABLE, "resource_update_date");    //修改时间
    QColumn<FileResource, Integer> resourceQuotedId = new QColumn<>(TABLE, "resource_quoted_id");    //所属文件引用id
    //所有字段
    QColumn<FileResource, ?>[] ALL_FIELDS = new QColumn[]{ resourceId , resourceName , resourceFolderPath , resourceFileName , resourceType , resourceCreateDate , resourceUpdateDate , resourceQuotedId};
    //endregion

    //查询处理 handle
    Handle<FileResource, ManyCondition> SELECT_WHERE_HANDLE = (bean) -> {
        ManyCondition conditions = new ManyCondition();
        if (bean.getResourceId() != null) {
            conditions.add(resourceId.toEqCondition(bean.getResourceId()));
        }
        if (bean.getResourceName() != null) {
            conditions.add(resourceName.toEqCondition(bean.getResourceName()));
        }
        if (bean.getResourceFolderPath() != null) {
            conditions.add(resourceFolderPath.toEqCondition(bean.getResourceFolderPath()));
        }
        if (bean.getResourceFileName() != null) {
            conditions.add(resourceFileName.toEqCondition(bean.getResourceFileName()));
        }
        if (bean.getResourceType() != null) {
            conditions.add(resourceType.toEqCondition(bean.getResourceType()));
        }
        if (bean.getResourceCreateDate() != null) {
            conditions.add(resourceCreateDate.toEqCondition(bean.getResourceCreateDate()));
        }
        if (bean.getResourceUpdateDate() != null) {
            conditions.add(resourceUpdateDate.toEqCondition(bean.getResourceUpdateDate()));
        }
        if (bean.getResourceQuotedId() != null) {
            conditions.add(resourceQuotedId.toEqCondition(bean.getResourceQuotedId()));
        }
        return conditions;
    };

    /**
    * 根据主键 查询
    */
    FileResource selectByResourceId(Integer resourceId);

    /**
    * 根据主键 更新
    */
    int updateByResourceId(FileResource bean);

    /**
    * 根据主键 更新指定字段
    */
    int updateSelectiveByResourceId(FileResource bean);


    /**
    * 根据主键 删除
    */
    int deleteByResourceId(Integer resourceId);

}